﻿using System.Threading.Tasks;
using Magicodes.ExporterAndImporter.Excel.AspNetCore;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc;
using NP.BPMReportPlatform.HSE.Dto;
using NP.BPMReportPlatform.PB.Dto;
using Volo.Abp.Application.Dtos;

namespace NP.BPMReportPlatform.PB
{
    /// <summary>
    /// 品保类 接口
    /// </summary>
    [Authorize]
    [ApiController]
    [Route("api/PB")]
    public class PBController : BPMReportPlatformController
    {
        private readonly IPBService _pbService;

        public PBController(IPBService pbService)
        {
            _pbService = pbService;
        }

        /// <summary>
        ///TU品保部模板配方及工艺变更通知 查询数据
        /// </summary>
        /// <param name="input"></param>
        /// <returns></returns>
        [HttpPost]
        [Route("TUPFGYBGTZ/GetAllAsync")]
        public async Task<PagedResultDto<TUPFGYBGTZOutput>> GetAllAsync([FromBody] GetTUPFGYBGTZInput input)
        {
            return await _pbService.GetAllAsync(input);
        }

        /// <summary>
        /// TU品保部模板配方及工艺变更通知  导出数据
        /// </summary>
        /// <param name="input"></param>
        /// <returns></returns>
        [HttpPost]
        [Route("TUPFGYBGTZ/ExportAsync")]
        public async Task<XlsxFileResult<TUPFGYBGTZOutput>> ExportAsync([FromBody] GetTUPFGYBGTZInput input)
        {
            var rst = await _pbService.ExportAsync(input);
            return new XlsxFileResult<TUPFGYBGTZOutput>(rst, "导出Excel");
        }
    }
}